﻿using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using ZoeEngine.Framework;

namespace ZoeEngine.Components.Graphics
{
    public abstract class BaseRenderComponent : EntityComponent, IDrawn
    {
        bool visible = true;
        int drawOrder;

        public virtual bool Visible
        {
            get
            {
                return visible;
            }
            set
            {
                if (visible != value)
                {
                    visible = value;
                    OnVisibleChanged(EventArgs.Empty);
                }
            }
        }
        public int DrawOrder
        {
            get
            {
                return drawOrder;
            }
            set
            {
                if (drawOrder != value)
                {
                    drawOrder = value;

                    OnDrawOrderChanged(EventArgs.Empty);
                }
            }
        }

        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch) { }
        public virtual void LoadContent() { }
        public virtual void UnloadContent() { }

        public event EventHandler DrawOrderChanged;
        public event EventHandler VisibleChanged;
        protected virtual void OnDrawOrderChanged(EventArgs e)
        {
            if (this.DrawOrderChanged != null)
            {
                this.DrawOrderChanged(this, e);
            }
        }
        protected virtual void OnVisibleChanged(EventArgs e)
        {
            if (VisibleChanged != null)
            {
                VisibleChanged(this, e);
            }
        }
    }
}
